/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ni;

import java.io.IOException;
import java.net.Socket;

/**
 *
 * @author Marianne Bellanger
 */
public class Gestion_Socket implements Runnable{
    private Socket sock;
    private byte[] message;
    private Downloader downloader;
    private Uploader uploader;

    public Gestion_Socket (Socket sock, byte[] message) throws IOException{
        this.sock = sock;
        this.message = message;
        uploader = new Uploader(sock);
        downloader = new Downloader(sock);
    }

    public void run() {
        try {
            message = downloader.receive();
            sock.close();
        } catch (IOException ex) {
            System.out.println("Rien en récepton");
        }
    }

    public void sendMessage (byte[] message) throws IOException{
        uploader.send(message);
    }

}
